<? include('header_html.php'); 
	$device = new objDevice($_GET['device_id']);	
	$device->os->getResources();
	$tab = $nms->getSubTab();
	$page = $nms->getPage();
?>
<div id="body">
	<div id="deviceInfo">
		<div class="header">
			<img src="/img/device/<?=$device->os->getType()?>.png" class="icon"  />
			<b><?=$device->description?></b>
			<span><?=$device->getHostName()?></span>
			<div class="tools">
				<a href="/deviceedit/<?=$device->id?>/" title="Delete" class="dialog">Delete</a>
<?	if ($device->useSNMP) { echo '<a href="#">Rediscover</a>'; } ?>
				<a href="/deviceedit/<?=$device->id?>/" title="Edit Device" class="dialog">Settings</a>
			</div>
		</div>
<? if ($device->isUp() && !$device->disabled) {		
		echo '<div class="status up"><span>'.$device->getUptime().'</span> Online</div>';
	} elseif  (!$device->disabled) {
		echo '<div class="status down"><span class="alerts">0</span>Offline </div>';
	} else {
		echo '<div class="status disabled">Disabled / Ignored</div>';
	}


	if (isset($device->os)) {
		$description = $device->os->getDescription();
		if (!empty($description)) {
			echo '<div class="param info">'.$device->os->getDescription().'</div>';
		}
	}	
	
	if (isset($device->cpus) && !empty($device->cpus)) {
		echo '<div class="param iconProcessors">';
		foreach ($device->cpus AS $i=>$cpu) {
			echo '<div graph="device='.$device->id.'&index='.$cpu->index.'&type=processorUsage&start=-1h&title=CPU '.$i.' - Usage over the last hour"><span>'.$cpu->getSpeed().'</span><a href="/device/'.$device->id.'/processors/#'.$cpu->index.'">'.$cpu->getDescription().'</a> </div>';		
		}
		echo '</div>';
	}
	if (isset($device->memory) && !empty($device->memory)) {
		echo '<div class="param iconMemory">';
		foreach ($device->memory AS $ram) {
			echo '<div graph="device='.$device->id.'&index='.$ram->index.'&type=storageUsage&start=-1h&title='.$ram->getDescription().' - Usage over the last hour"><span>'.$ram->getSize().'</span><a href="/device/'.$device->id.'/system/memory/#'.$memory->index.'">'.$ram->getDescription().'</a> </div>';		
		}
		echo '</div>';
	}
	if (isset($device->interfaces) && !empty($device->interfaces)) {

		echo '<div class="param iconInterfaces">';
		foreach ($device->interfaces AS $interface) {
			if (!$interface->ignore) {
				echo '<div graph="device='.$device->id.'&index='.$interface->ifIndex.'&type=interfaceTraffic&start=-1h"><span>'.$interface->getSpeed().'</span><a href="/device/'.$device->id.'/interface/'.$interface->ifIndex.'/">'.$interface->getDescription().'</a></div>';		
	
			}
		}
		echo '</div>';

	}
	if (isset($device->storage) && !empty($device->storage)) {
		echo '<div class="param iconStorage">';
		foreach ($device->storage AS $storage) {
			echo '<div graph="device='.$device->id.'&index='.$storage->index.'&type=storageUsage&start=-1h&title='.$storage->getDescription().' - Usage over the last hour"><span>'.$storage->getSize().'</span> <a href="/device/'.$device->id.'/system/storage/#'.$storage->index.'" >'.$storage->getDescription().'</a></div>';		
		
		}
		echo '</div>';
	}
	if (!empty($device->contactName)) {
		echo '<div class="param iconContact">';
			if (!empty($device->contactEmail)) {
				echo '<a href="mailto:'.$device->contactEmail.'" class="right email">&nbsp;</a>';
			}
			echo '<a href="/contact/'.$device->contactName.'/">'.$device->contactName.'</a>';
		echo '</div>'; 
	}
	if (!empty($device->location)) {
		echo '<div class="param location">'.$device->location.'</div>'; 
	}
?>	
	</div>


	<div id="tabPanel">		
		<div class="tabs">
			<a href="/device/<?=$device->id?>/" class="<?=$tab=='summary'?'active':''?>">Summary</a>
<? foreach ($device->os->tabs AS $tabID=>$label) {
	echo '<a href="/device/'.$device->id.'/'.$tabID.'/" class="'.($tab==$tabID?'active':'').'">'.$label.'</a>';
}?>			
		</div>
		<div class="tab <?=(empty($page)?$tab:$page)?>">			
			<? include($nms->getSubTabPath($device->os->getType()));?>
		</div>
	</div>
</div>
<script type="text/javascript">
	$('*[graph]').tooltip({ 
		track: true, 
		delay: 2000, 
		showURL: false, 
		bodyHandler: function() { 
			return $("<img/>").attr({
				src:'/graph.php?width=600&height=400&legend=1&font=fff&frame=fff&'+this.getAttribute('graph'),
				width:600,
				height:400
			}); 
		},
		fade: 100,
		extraClass: 'graph'
	}).click(function () {
		window.location.href='/graph/?width=1200&height=800&legend=1&'+this.getAttribute('graph');	
	});
</script>
<pre><?
//echo print_r($device,1)
?></pre>
<? include('footer_html.php'); ?>